/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bsd5ex.group1.kaokang.servlet;

import com.bsd5ex.group1.kaokang.MenuGenerator;
import com.bsd5ex.group1.kaokang.helper.FoodHelper;
import java.io.IOException;
import java.io.PrintWriter;
 
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 *
 * @author VAIO
 */
public class FoodEntryServlet extends HttpServlet {

    
    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        FoodHelper.addFood(req.getParameter("foodName"), 
                0, 
                Integer.parseInt(req.getParameter("unitTypeId")), 
                Integer.parseInt(req.getParameter("kitchenWareId")), 
                Integer.parseInt(req.getParameter("seasonId")), 
                Integer.parseInt(req.getParameter("foodTypeId")), 
                Integer.parseInt(req.getParameter("pickingId")));
        
        req.setAttribute("test", "test");
        getServletContext().getRequestDispatcher("/food.jsp").forward(req, resp); 
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        int step = Integer.parseInt(req.getParameter("step"));
        
        switch( step ) {
            case 1: 
                FoodHelper.prepareAddFoodForm(req);
                getServletContext().getRequestDispatcher("/back-office/bom/index.jsp").forward(req, resp); 
                break;
        }
        
    }

    @Override
    public void destroy() {
        super.destroy();
    }
    
}
